package com.farm.web.dao;

import com.farm.web.pojo.CustUser;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

@Repository
public interface CustUserMapper extends Mapper<CustUser> {

    //修改用户密码
    @Update("update t_cust_user set password=#{password} where username=#{username}")
    int updatePassword(CustUser custUser);

    //根据id查询用户和角色的中间表
    @Select("select count(0) from t_cust_user_role where user_id=#{userId}")
    int selectUserAndRole(Integer userId);

    //删除用户和角色的中间表
    @Delete("delete from t_cust_user_role WHERE user_id=#{userId}")
    void deleteUserAndRole(Integer userId);

    @Insert("INSERT INTO t_cust_user_role(user_id,role_id) VALUES(#{id},#{roleId}) ")
    void addUserAndRole(@Param("id") Integer id,@Param("roleId") Integer roleId);

    @Select("select id,customer_id,name,username,status,type from t_cust_user where customer_id=#{customer_id}")
    void findAll(String customer_id);

}
